﻿$(function() {
    $("form").validate({
        rules: { txt_rolename: "required", txt_description: "required" },
        submitHandler: function() {

            $("#btn_submit").attr("disabled", "disabled").after("<span>提交中.....</span>");

            $.ajax({
                type: "POST",
                url: "../api/access.ashx",
                data: { type: 'addrole', rolename: $('#txt_rolename').val(), desc: $("#txt_description").val() },
                dataType: "html",
                success: function(data) {
                    if (data == 1) {
                        facebox("创建身份成功！");
                    }
                    else {
                        facebox("创建身份失败！");
                    }
                    $("#txt_rolename").val("");
                    $("#txt_description").val("");
                    $("#btn_submit").attr("disabled", "").next("span").remove();
                }
            });
        }
    })
    formReady();
});